<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;">
        <form id="userAddForm" action="#(ctx)/admin/user/userAdd" method="post" enctype="multipart/form-data">
            <table class="grid">
                <tr>
                    <div class="form-item">
                        <td><label for="" class="label-top">用户名：</label></td>
                        <td><input name="username" class="easyui-validatebox easyui-textbox" prompt="请输入用户名"
                                   data-options="required:true,validType:'length[3,10]'"></td>
                    </div>
                </tr>
                <tr>
                    <div class="form-item">
                        <td><label for="" class="label-top">密码：</label></td>
                        <td><input name="password" class="easyui-passwordbox" prompt="Password" iconWidth="28"
                                   data-options="required:true,validType:'length[3,10]'"></td>
                    </div>
                </tr>
                <tr>
                    <div class="form-item">
                        <td><label for="" class="label-top">描述：</label></td>
                        <td><input name="userDesc" class="easyui-validatebox easyui-textbox" prompt="请输入用户名"
                                   data-options="required:true,validType:'length[3,10]'"></td>
                    </div>
                </tr>
                <tr>
                    <div class="form-item">
                        <td><label for="" class="label-top">角色：</label></td>
                        <td>
                            <input id="roleId" name="roleId" prompt="请选择角色" value="" width="161.778px"
                                   class="easyui-validatebox" data-options="required:true">
                        </td>
                    </div>
                </tr>
                <tr>
                    <div class="form-item">
                        <td><label for="" class="label-top">头像：</label></td>
                        <td><input name="logo" class="easyui-filebox"
                                   data-options="buttonText:'上传头像',buttonIcon:'fa fa-upload'">
                        </td>
                    </div>
                </tr>
                <tr>
                    <td colspan="2">
                        <div align="center" style="margin-top: 10px;">
                            <button href="#" class="easyui-linkbutton" data-options="iconCls:'fa fa-save'"
                                    type="submit">
                                保存
                            </button>
                        </div>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<script>
    $(document).ready(function () {
        var userAddForm = $('#userAddForm')
        $('#roleId').combobox({
            url: '#(ctx)/admin/roleMenu/roleCombo',
            editable: false,
            valueField: 'roleId',
            textField: 'roleName'
        });

        userAddForm.ajaxForm({
            dataType: "json",
            beforeSubmit:function () {
                progressLoad();
                var isValid = $('#userAddForm').form('validate');
                if (!isValid) {
                    progressClose();
                    parent.$.messager.show({
                        title: '警告',
                        msg: '您的输入不合法',
                        timeout: 3000,
                        showType: 'slide'
                    });
                }
                return isValid;
            },
            success: function (response) {
                progressClose();
                if (response.result) {
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    var msg = JSON.stringify(response.msg);
                    parent.$.messager.alert('提示', msg, 'warning');
                }
                return;
            }
        });
    });
</script>